using System;
using NUnit.Framework;
using DreamPark;
using System.Collections.Generic;

namespace Tests_Parking
{
	[TestFixture()]
	public class Test_Parking
	{
		[Test()]
		public void Test_Instanciation () {
			Parking parking = new Parking(25);
			
			Assert.AreEqual(25, parking.PlacesMax);
		}
		
		[Test()]
		public void Test_GarerVehicule() {
			Parking parking = new Parking(25);
			Place p = new Place(1, 0, 500, 600);
			parking.AjouterPlace(p);
			Ticket ticket = parking.GarerVehicule(1, TypeVehicule.Voiture);
			
			Assert.AreEqual(ticket.Place.NumeroPlace, 1);
		}
		
		[Test()]
		public void Test_ReprendreVehicule() {
			Parking parking = new Parking(25);
			Place p = new Place(1, 0, 500, 600);
			parking.AjouterPlace(p);
			Ticket ticket = parking.GarerVehicule(1, TypeVehicule.Voiture);
			
			bool occupee = false;
			foreach (Place place in parking.Places) {
				if (place.NumeroPlace == 1) {
					occupee = place.Occupee;
				}
			}
			
			Assert.AreEqual(occupee, true);
			
			parking.ReprendreVehicule(ticket.NumeroTicket);
			
			foreach (Place place in parking.Places) {
				if (place.NumeroPlace == 1) {
					occupee = place.Occupee;
				}
			}
			Assert.AreEqual(occupee, false);
		}
	}
}

